/**
 * @mainpage DataTime
 * @author Alberto De Pena
 *
 * This is a class that uses the ctime library which returns the amount of seconds since
 * January 1 1970 until now to facilitate the user with a set of functions to manipulate
 * such data.
 */
/**
 * @file Date.hpp
 * 
 * This header file contains the prototypes of the functions needed to manipulate a DateTime 
 * object.
 */
#include <ctime>
#include <string>

/**
 * The namespace util encapsulates the prototype (declarations) of the functions that will be
 * available for the user to incorporate in his/her program.
 */
namespace util
{
    enum TimeUnit { SECONDS, MINUTES, HOURS, DAYS, MONTHS, YEARS };
/**
 * This class specifies the manner in which the DateTime object can be implemented.
 */
    class DateTime
    {
    public:
		DateTime();
		DateTime( std::time_t time );
		DateTime( int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0 );

		static DateTime now();

        void set( std::time_t time );
        void set( int year, int month= 1, int day= 1, int hour= 0, int minute= 0, int second= 0 );

        void offset( int amount, TimeUnit unit );

        bool equals( const DateTime &other ) const;
        bool before( const DateTime &other ) const;
        bool after( const DateTime &other ) const;

        std::string getString() const;
		static std::string getFormatString();

		static void setFormatString( std::string value );

        int getSecond() const;
        void setSecond( int value );

        int getMinute() const;
        void setMinute( int value );

        int getHour() const;
        void setHour( int value );

        int getDay() const;
        void setDay( int value );

        int getMonth() const;
        void setMonth( int value );

        int getYear() const;
        void setYear( int value );

        int getDayOfWeek() const;
        int getDayOfYear() const;
         
    private:
        //time is a integer type variable that holds the amount of seconds since Jan 1, 1970
        time_t time;
        //Declaration of a struct to be in used for storing the time broken down in a more understandable way.
        tm time_struct;
		//Variable that contains the format string to be used (initial value: "%a %b %d %H:%M:%S %Y").
		static std::string format_string;
    };

/**
 * This class throws an exception every time the user sets the DateTime object to an invalid value no matter which case.
 */
	class InvalidDateTimeValue
	{
	public:
		InvalidDateTimeValue( std::string message );

		const char* what() const;
	private:
		//Variable that contains a specific message to throw an exception when invalid date has been entered.
		std::string error_message;
	};
}
